package com.n9.qq.android.login.tlv;

import com.n9.qq.util.Util;

import java.util.Objects;

/**
 * @author ice
 * @since 2019/2/12 11:16
 */
public class Tlv0142 extends BaseTlv {

    int h = 0;
    int len = 0;

    public Tlv0142() {
        this.cmd = 0x0142;
    }

    /**
     * @param appPackeageNameBytes
     * @return
     */
    public byte[] getData(byte[] appPackeageNameBytes) {
        int j = 32;
        if (Objects.isNull(appPackeageNameBytes)) {
            appPackeageNameBytes = new byte[0];
        }
        j = appPackeageNameBytes.length > 32 ? j : appPackeageNameBytes.length;

        this.len = j + 4;
        byte[] data = new byte[this.len];
        Util.int16_to_buf(data, 0, this.h);
        Util.int16_to_buf(data, 2, j);
        System.arraycopy(appPackeageNameBytes, 0, data, 4, j);
        return this.getBufData(data);
    }
}
